<?php

class CriteriaCollection {

    /**
     * @var Criteria[]
     */
    protected $collection;

    /**
     * @return string
     */
    public function getCriteriaString() {
        $criteriaString = '';
        foreach($this->collection as $criteria) {
            $criteriaString .= $criteria->getCriteriaString();
        }
        return $criteriaString;
    }

    /**
     * @param Criteria $criteria
     */
    public function addCriteria($criteria) {
        if($this->getCriteriaCount() > 0)
        {
            $criteria->validateAndSetCriteriaConnector(Criteria::AND_EXPRESSION);
        }
        $this->collection[] = $criteria;
    }

    /**
     * @param Criteria $criteria
     */
    public function addOrCriteria($criteria) {
        $criteria->validateAndSetCriteriaConnector(Criteria::OR_EXPRESSION);
        $this->collection[] = $criteria;
    }

    /**
     * @return int
     */
    public function getCriteriaCount() {
        return count($this->collection);
    }

}